package com.lumyc.store.controller;

import com.lumyc.store.service.ex.ServiceException;
import com.lumyc.store.service.ex.UserDuplicateException;
import com.lumyc.store.util.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;

public class BaseController {

    public static final int OK = 200;
    @ExceptionHandler(ServiceException.class)
    public JsonResult<Void> handleException(Throwable e){
        JsonResult<Void> result = new JsonResult<>(e);
        if(e instanceof UserDuplicateException){
            result.setState(4000);
        }
        return result;
    }
}
